package com.cnhis.cloudhealth.clidoctorweb.clisendadvice;

import java.math.BigDecimal;
import java.util.Map;

import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import org.jboss.resteasy.logging.Logger;
import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Reference;
import com.cnhis.cloudhealth.clinical.clidoctor.clisendadvice.service.ICliSendAdvice;
import com.cnhis.cloudhealth.commons.Mappers.ModelVo;
import com.cnhis.cloudhealth.commons.utils.JsonUtil;
import com.cnhis.cloudhealth.commons.utils.StaticKeys;

import java.util.HashMap;
@Path("clisendadvice")
@Component("CliSendAdviceRest")
public class CliSendAdviceRest {
	Logger log = Logger.getLogger(CliSendAdviceRest.class); 
	@Reference
	private ICliSendAdvice iCliSendAdvice;
	
	/**
	 * Clinic_Advice_Send_Pretreat
	 * 临嘱发送预处理
	 * @param lXml
	 * @param lSign
	 * @param lBCE01
	 * @param lBCE02
	 * @param lBCE03
	 * @param lBCK01
	 * @param lACF01
	 * @param lVAA07
	 * @param lVAA01
	 * @param lVer
	 * @param ReVAJ38
	 * @param reBEP06
	 * @param ReVAJ38a
	 * @return
	 * @throws Exception
	 */
	@POST
	@Path("clinicadvicesendpretreat")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo clinicAdviceSendPretreat(@FormParam("params") String params) throws Exception{
		Map map = JsonUtil.getMap(params);
		return iCliSendAdvice.clinicAdviceSendPretreat(map);
	}
	
	
	/**
	 * Clinic_Advice_Send
	 * 临嘱发送
	 * @param lXml 2：门诊划价；3：门诊记账
	 * @param lSign
	 * @param lBCE01
	 * @param lBCE02当前操作员编号
	 * @param lBCE03当前操作员姓名
	 * @param lBCK01开单科室
	 * @param lACF01
	 * @param lVAA07
	 * @param lVAA01
	 * @param lVer
	 * @param ReVAIid output
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@POST
	@Path("clinicadvicesend")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo clinicAdviceSend(
			@FormParam("lXml") String lXml,
			@FormParam("lSign") Integer lSign,
			@FormParam("lBCE01") Integer lBCE01,
			@FormParam("lBCE02") String lBCE02,
			@FormParam("lBCE03") String lBCE03,
			@FormParam("lBCK01") Integer lBCK01,
			@FormParam("lACF01") Integer lACF01,
			@FormParam("lVAA07") Long lVAA07,
			@FormParam("lVAA01") Long lVAA01,
			@FormParam("lVer") String lVer,
			@FormParam("savePrintList") String savePrintList,
			@FormParam("ReVAIid") String ReVAIid) throws Exception{
		Map map = new HashMap();
		map.put("lXml",lXml);
		map.put("lSign",lSign);
		map.put("lBCE01",lBCE01);
		map.put("lBCE02",lBCE02);
		map.put("lBCE03",lBCE03);
		map.put("lBCK01",lBCK01);
		map.put("lACF01",lACF01);
		map.put("lVAA07",lVAA07);
		map.put("lVAA01",lVAA01);
		map.put("lVer",lVer);
		map.put("ReVAIid",ReVAIid);
		map.put("savePrintList",savePrintList);
		return iCliSendAdvice.clinicAdviceSend(map);
	}
	/* ScriptId(830) */
	/* Description(门诊医嘱发送－－查询需要发送的医嘱) */
	@SuppressWarnings({ "unchecked" })
	@POST
	@Path("querysendadvice")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo querySendAdvice(
			@FormParam("lVaf06") int lVaf06,
			@FormParam("lCheck") int lCheck,
			@FormParam("lVAF04") int lVAF04,
			@FormParam("lVAF10A") int lVAF10A,
			@FormParam("lVAF10B") int lVAF10B,
			@FormParam("lVAF10C") int lVAF10C,
			@FormParam("BCE01") int BCE01,
			@FormParam("lVAF11A") int lVAF11A,
			@FormParam("lVAF11B") int lVAF11B,
			@FormParam("lType") int lType,
			@FormParam("lDay") int lDay
			)throws Exception{
		HashMap map = new HashMap();
		map.put("lVaf06", lVaf06);
		map.put("lCheck",lCheck);
		map.put("lVAF04", lVAF04);
		map.put("lVAF10A",lVAF10A);
		map.put("lVAF10B", lVAF10B);
		map.put("lVAF10C", lVAF10C);
		map.put("BCE01", BCE01);
		map.put("lVAF11A", lVAF11A);
		map.put("lVAF11B", lVAF11B);
		map.put("lType",lType);
		map.put("lDay",lDay);
		return iCliSendAdvice.querySendAdvice(map);
	}
	
	/* 新增wj*/
	/* Description(门诊医嘱发送－－查询需要发送的医嘱的计价信息) */
	@SuppressWarnings({ "unchecked" })
	@GET
	@Path("getVbdInfo")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo getVbdInfo(
	    @QueryParam("bby01s") String bby01s
	    )throws Exception{
	    HashMap map = new HashMap();
	    map.put("bby01s", bby01s);
	    return iCliSendAdvice.getVbdInfo(map);
	}
	/* ScriptId(1770) */
	/* Description(用于执行或发送医嘱时，判断是否药品) */
	/**
	 * 
	 * @param BBY01 收费项目id
	 * @param BDN01 类型  4 
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@POST
	@Path("checkwhetherdurg")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo checkWhetherDurg(@FormParam("BBY01") int BBY01,
			@FormParam("BDN01") String BDN01)throws Exception{
		HashMap map = new HashMap();
		map.put("BBY01", BBY01);
		map.put("BDN01",BDN01);
		return iCliSendAdvice.checkWhetherDurg(map);
	}
	/* ScriptId(7307) */
	/* Description(判断是否会员一卡通扣费病人) */
	/**
	 * 
	 * @param VAA01 病人id
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings({ "unchecked" })
	@POST
	@Path("checkwhethervip")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo checkWhetherVIP(@FormParam("VAA01") int VAA01)throws Exception{
		HashMap map = new HashMap();
		map.put("VAA01", VAA01);
		return iCliSendAdvice.checkWhetherVIP(map);
	}
	/*GetItemExecDept*/
	/*获取收费项目执行科室*/
	/**
	 * 
	 * @param lACF01 业务id
	 * @param lVAA07 就诊id 或 登记id
	 * @param lBBY01 收费项目id
	 * @param lBCK01 开单人所对应科室
	 * @param lBCK01A -操作员科室  
	 * @param lSign 0:财务 1:临床护理 2:手术站 3:医技
	 * @param lDrugDept
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings({ "unchecked" })
	@POST
	@Path("getfeeitemexecutionoffices")
	@Produces({ MediaType.APPLICATION_JSON })
	  public ModelVo getFeeItemExecutionOffices(
			  @FormParam("lACF01") int lACF01,
			  @FormParam("lVAA07") int lVAA07,
			  @FormParam("lBBY01") int lBBY01,
			  @FormParam("lBCK01") int lBCK01,
			  @FormParam("lBCK01A") int lBCK01A,
			  @FormParam("lSign") int lSign,
			  @FormParam("lDrugDept") int lDrugDept
			  )throws Exception{
		  HashMap map = new HashMap();
		  map.put("lACF01", lACF01);
		  map.put("lVAA07", lVAA07);
		  map.put("lBBY01", lBBY01);
		  map.put("lBCK01", lBCK01);
		  map.put("lBCK01A", lBCK01A);
		  map.put("lSign", lSign);
		  map.put("lDrugDept", lDrugDept);
		  return iCliSendAdvice.getFeeItemExecutionOffices(map);
	  }
	/*HORate_Card_Balance*/
	//验证卡余额
	/**
	 * 
	 * @param VAA01 病人id
	 * @param VAA07
	 * @param VAJ38
	 * @param Rvalue
	 * @param VBU14
	 * @param VBU15
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings({ "unchecked" })
	@POST
	@Path("cardbalance")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo  cardBalance(
			@FormParam("VAA01") int VAA01,
			@FormParam("VAA07") int VAA07,
			@FormParam("VAJ38") BigDecimal VAJ38,
			@FormParam("Rvalue") int Rvalue,
			@FormParam("VBU14") BigDecimal VBU14,
			@FormParam("VBU15") BigDecimal VBU15
			)throws Exception{
		  HashMap map = new HashMap();
		  map.put("VAA01", VAA01);
		  map.put("VAA07", VAA07);
		  map.put("VAJ38", VAJ38);
		  map.put("Rvalue", Rvalue);
		  map.put("VBU14", VBU14);
		  map.put("VBU15", VBU15);
		  return iCliSendAdvice.cardBalance(map);
	}
	
	/**
	 * 查询参数
	 */
	@GET
	@Path("getSystemParam")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo getSystemParam(@QueryParam("params") String params)throws Exception{
	    ModelVo mv = new ModelVo();
	    try
	    {
	        Map<String,Object> map = JsonUtil.getMap(params);
	        map.put("value", iCliSendAdvice.getSystemParam(map));
	        mv.setMap(map);
	        mv.setResult(StaticKeys.OH_SUCCESS);
	        return mv;
	    }
	    catch(Exception e)
	    {
	        e.printStackTrace();
	        mv.setResult(StaticKeys.OH_FALSE);
            return mv;
	    }
	}
}



